package com.cskaoyan.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

/**
 * @author stone
 * @date 2022/07/11 17:25
 */
@RequestMapping("mv")
@Controller
public class MvController {

    @RequestMapping("hello")
    public ModelAndView hello(HttpServletRequest request) {
        String fromId = request.getParameter("fromId");
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("/hello.jsp");
        modelAndView.addObject("key1", "mv");
        modelAndView.addObject("key2", "songge@cskaoyan.com");
        return modelAndView;
    }

    @RequestMapping("hello2")
    public String hello2(Model model) {
        model.addAttribute("key1", "mv");
        model.addAttribute("key2", "ligenli@cskaoyan.com");
        return "/hello.jsp";
    }
}
